<?php
/**
 * @Author: Xu Liu email:2867557054@qq.com
 * @Date:   2016-12-15 13:31:33
 * @Last Modified by:   Xu Liu
 * @Last Modified time: 2018-01-03 21:35:40
 */
if (!defined('IN_ADMINCP') || !defined('IN_DISCUZ')) {
    exit('Access Denied');
}
$sql = <<<EOF
CREATE TABLE IF NOT EXISTS `cdb_jamesonread_appuser` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `uid` int(11) unsigned NOT NULL,
  `qqopenid` varchar(255)  NOT NULL DEFAULT '0',
  `wxopenid` varchar(255)  NOT NULL DEFAULT '0',
  `qqname` varchar(255)  NOT NULL DEFAULT '0',
  `wxname` varchar(255)  NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`)
);
CREATE TABLE IF NOT EXISTS `cdb_jamesonread_appguanzhu` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `uid` int(11) unsigned NOT NULL,
  `bbsuid` int(11) unsigned NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`)
);
DROP TABLE IF EXISTS `cdb_jamesonread_pdf`;
CREATE TABLE `cdb_jamesonread_pdf` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `book_id` int(11) NOT NULL,
  `ordernum` int(5) NOT NULL,
  `name` varchar(255) NOT NULL,
  `url` varchar(255) NOT NULL,
  `addtime` int(11) NOT NULL,
  KEY `book_id` (`book_id`),
  PRIMARY KEY (`id`)
);
DROP TABLE IF EXISTS `cdb_jamesonread_search`;
CREATE TABLE `cdb_jamesonread_search` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `keyword` varchar(255) NOT NULL,
  `tag` varchar(255) DEFAULT NULL,
  `counts` int(11) NOT NULL,
  `tagcounts` int(11) DEFAULT '0',
  `addtime` int(11) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `tag` (`tag`),
  KEY `keyword` (`keyword`)
);
DROP TABLE IF EXISTS `cdb_jamesonread_piao`;
CREATE TABLE `cdb_jamesonread_piao` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `uid` int(11) unsigned NOT NULL,
  `username` varchar(255) NOT NULL,
  `type` int(2) unsigned NOT NULL DEFAULT '1',
  `addtime` int(11) unsigned NOT NULL,
  `exid` varchar(255) NOT NULL,
  `money` int(11) unsigned NOT NULL,
  `number` int(11) unsigned NOT NULL,
  `name` varchar(255) NOT NULL,
  `book_id` int(11) unsigned NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`)
);
DROP TABLE IF EXISTS `cdb_jamesonread_shenhe`;
CREATE TABLE `cdb_jamesonread_shenhe` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `uid` int(11) unsigned NOT NULL,
  `groupid` int(11) NOT NULL DEFAULT '1',
  `status` tinyint(2) NOT NULL DEFAULT '0',
  `addtime` int(11) unsigned NOT NULL,
  `xingming` varchar(255) NOT NULL,
  `lianxi` varchar(255) NOT NULL,
  `fuyan` varchar(255) NOT NULL,
  `author` varchar(255) NOT NULL,
  PRIMARY KEY (`id`)
);
DROP TABLE IF EXISTS `cdb_jamesonread_authors`;
CREATE TABLE `cdb_jamesonread_authors` (
  `author_id` int(11) unsigned NOT NULL,
  `status` int(2) unsigned NOT NULL DEFAULT '1',
  `edit` int(2) unsigned NOT NULL DEFAULT '1',
  `allowedit` int(2) unsigned NOT NULL DEFAULT '1',
  `zgsj` int(11) unsigned NOT NULL DEFAULT '0',
  `qzsj` int(11) unsigned NOT NULL DEFAULT '0',
  `setsj` varchar(255) NOT NULL DEFAULT 'zgsj',
  `yuepiao` int(11) unsigned NOT NULL DEFAULT '0',
  `tuijianpiao` int(11) unsigned NOT NULL DEFAULT '0',
  `cuigengpiao` int(11) unsigned NOT NULL DEFAULT '0',
  `groupid` int(11) NOT NULL DEFAULT '0',
  PRIMARY KEY (`author_id`)
);
INSERT INTO `cdb_jamesonread_authors` (`author_id`,`status`,`edit`,`allowedit`,`zgsj`,`qzsj`,`setsj`,`yuepiao`,`tuijianpiao`,`cuigengpiao`) VALUES (1,1,1,1,0,0,'zgsj',0,0,0);
DROP TABLE IF EXISTS `cdb_jamesonread_bookmarks`;
CREATE TABLE IF NOT EXISTS `cdb_jamesonread_bookmarks` (
    `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
    `uid` int(11) unsigned NOT NULL,
    `book_id` int(11) unsigned NOT NULL,
    `addtime` int(11) unsigned NOT NULL DEFAULT '0',
    `tid` int(11) unsigned NOT NULL,
    `hash` varchar(255) NOT NULL DEFAULT '0',
    PRIMARY KEY (`id`),
    KEY `book_id` (`book_id`),
    KEY `tid` (`tid`),
    KEY `uid` (`uid`)
  );
DROP TABLE IF EXISTS `cdb_jamesonread_fx`;
CREATE TABLE IF NOT EXISTS `cdb_jamesonread_fx` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `fxuid` int(11) unsigned NOT NULL,
  `ip` varchar(255) NOT NULL,
  `addtime` int(11) unsigned NOT NULL,
  `tid` int(11) unsigned NOT NULL,
  `jiangli` int(11) unsigned NOT NULL,
  `book_id` int(11) unsigned NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`),
  KEY `book_id` (`book_id`),
  KEY `fxuid` (`fxuid`)
);
DROP TABLE IF EXISTS `cdb_jamesonread_yongjin`;
CREATE TABLE `cdb_jamesonread_yongjin` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `buy_id` int(11) unsigned NOT NULL,
  `author_id` int(11) unsigned NOT NULL,
  `book_id` int(11) unsigned NOT NULL,
  `saleprice` int(11) unsigned NOT NULL,
  `yongjinbi` float(4,1) unsigned NOT NULL,
  `yongjin` int(11) unsigned NOT NULL,
  `addtime` int(11) unsigned NOT NULL,
  `type` int(2) unsigned NOT NULL DEFAULT '1',
  KEY `book_id` (`book_id`),
  KEY `buy_id` (`buy_id`),
  KEY `author_id` (`author_id`),
  PRIMARY KEY (`id`)
);
DROP TABLE IF EXISTS `cdb_jamesonread_dashang`;
CREATE TABLE `cdb_jamesonread_dashang` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `uid` int(11) unsigned NOT NULL,
  `authorid` int(11) unsigned NOT NULL,
  `addtime` int(11) unsigned NOT NULL,
  `price` int(11) unsigned NOT NULL,
  `book_id` int(11) unsigned NOT NULL,
  `tid` int(11) unsigned NOT NULL,
  `pid` int(11) unsigned DEFAULT NULL,
  `username` varchar(255) NOT NULL,
  KEY `uid` (`uid`),
  KEY `book_id` (`book_id`),
  KEY `authorid` (`authorid`),
  PRIMARY KEY (`id`)
);
DROP TABLE IF EXISTS `cdb_jamesonread_buybooks`;
CREATE TABLE `cdb_jamesonread_buybooks` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `buy_id` int(11) unsigned NOT null,
  `author_id` int(11) unsigned NOT NULL,
  `book_id` int(11) unsigned NOT NULL,
  `category_id` int(11) unsigned NOT NULL,
  `price` int(8) unsigned NOT NULL DEFAULT '0',
  `addtime` int(11) unsigned NOT NULL,
  KEY `buy_id` (`buy_id`),
  KEY `book_id` (`book_id`),
  KEY `bidbuyid` (`buy_id`,`book_id`),
  PRIMARY KEY (`id`)
);
DROP TABLE IF EXISTS `cdb_jamesonread_buytids`;
CREATE TABLE `cdb_jamesonread_buytids` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `buy_id` int(11) unsigned NOT NULL,
  `author_id` int(11) unsigned NOT NULL,
  `tid` int(11) unsigned NOT NULL,
  `category_id` int(11) unsigned NOT NULL,
  `addtime` int(11) unsigned NOT NULL,
  `price` int(11) unsigned NOT NULL DEFAULT '0',
  `book_id` int(11) unsigned NOT NULL,
  KEY `buy_id` (`buy_id`),
  KEY `tid` (`tid`),
  PRIMARY KEY (`id`)
);
DROP TABLE IF EXISTS `cdb_jamesonread_colums`;
CREATE TABLE `cdb_jamesonread_colums` (
  `colum_id` int(11)  unsigned NOT NULL AUTO_INCREMENT,
  `category_id` int(11) unsigned  NOT NULL,
  `uid` int(11) unsigned  NOT NULL,
  `fid` int(11) unsigned  NOT NULL,
  `book_id` int(11) unsigned  NOT NULL,
  `tid` int(11) unsigned  NOT NULL,
  `zhangjie` bigint(18) unsigned  NOT NULL,
  `addtime` int(11)  unsigned NOT NULL,
  `j_id` int(11) unsigned DEFAULT NULL,
  `subject` varchar(255) DEFAULT NULL,
  `price` int(8) unsigned DEFAULT '0',
  `pid` int(11) unsigned DEFAULT '0',
  `length` int(11) unsigned DEFAULT '0',
  `caijiid` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`colum_id`),
  KEY `book_id` (`book_id`),
  KEY `j_id` (`j_id`),
  KEY `addtime` (`addtime`),
  KEY `timezhangjie` (`addtime`,`zhangjie`),
  KEY `bidjidzhangjie` (`book_id`,`j_id`,`zhangjie`),
  KEY `tid` (`tid`)
);
DROP TABLE IF EXISTS `cdb_jamesonread_dianping`;
CREATE TABLE `cdb_jamesonread_dianping` (
  `dp_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `book_id` int(11) unsigned NOT NULL,
  `text` text NOT NULL,
  `uid` int(11) unsigned NOT NULL,
  `addtime` int(11) unsigned NOT NULL,
  `yinyongtext` text,
  `fandui` int(8) unsigned NOT NULL DEFAULT '0',
  `zhichi` int(8) unsigned NOT NULL DEFAULT '0',
  PRIMARY KEY (`dp_id`),
  KEY `book_id` (`book_id`),
  KEY `bidtime` (`book_id`,`addtime`)
);
DROP TABLE IF EXISTS `cdb_jamesonread_favores`;
CREATE TABLE `cdb_jamesonread_favores` (
  `favore_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `book_id` int(11) unsigned NOT NULL,
  `uid` int(11) unsigned NOT NULL,
  `status` tinyint(1) unsigned NOT NULL DEFAULT '1',
  PRIMARY KEY (`favore_id`),
  KEY `book_id` (`book_id`),
  KEY `uid` (`uid`)
);
DROP TABLE IF EXISTS `cdb_jamesonread_fenjuan`;
CREATE TABLE `cdb_jamesonread_fenjuan` (
  `j_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `j_title` varchar(255) NOT NULL,
  `book_id` int(11) unsigned NOT NULL,
  `order_num` int(3) unsigned DEFAULT '1',
  PRIMARY KEY (`j_id`),
  KEY `book_id` (`book_id`),
  KEY `bookidordernum` (`book_id`,`order_num`)
);
DROP TABLE IF EXISTS `cdb_jamesonread_scores`;
CREATE TABLE `cdb_jamesonread_scores` (
  `score_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `book_id` int(11) unsigned NOT NULL,
  `uid` int(11) unsigned NOT NULL,
  `score` int(8) unsigned NOT NULL,
  `addtime` int(11) unsigned NOT NULL,
  PRIMARY KEY (`score_id`),
  KEY `book_id` (`book_id`)
);
DROP TABLE IF EXISTS `cdb_jamesonread_books`;
CREATE TABLE `cdb_jamesonread_books` (
  `book_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `ordernum` int(6) unsigned  NOT NULL DEFAULT '1',
  `uid` int(11) unsigned  NOT NULL DEFAULT '1',
  `category_id`   int(11) unsigned NOT NULL,
  `parent_id`   int(11) unsigned DEFAULT '0',
  `book_name` char(255) NOT NULL,
  `views` int(8) unsigned  NOT NULL DEFAULT '1',
  `author` char(255) NOT NULL,
  `desco` text,
  `addtime` int(11) unsigned NOT NULL,
  `image` char(255) DEFAULT NULL,
  `is_display` tinyint(1) unsigned  NOT NULL DEFAULT '1',
  `is_top` tinyint(2) unsigned  NOT NULL DEFAULT '0',
  `plan` int(8) unsigned  NOT NULL DEFAULT '0',
  `favores` int(11) unsigned  NOT NULL DEFAULT '0',
  `scores` int(11) unsigned  NOT NULL DEFAULT '0',
  `dpcount` int(11) unsigned  NOT NULL DEFAULT '0',
  `fletter` char(20) DEFAULT NULL,
  `bookmoney` int(8) unsigned NOT NULL DEFAULT '0',
  `status` int(2) unsigned  NOT NULL DEFAULT '1',
  `is_jingxuan` int(2) unsigned NOT NULL DEFAULT '0',
  `is_tuwen` int(2) unsigned NOT NULL DEFAULT '0',
  `bindfid` int(11) unsigned NOT NULL DEFAULT '0',
  `qzfid` int(11) unsigned NOT NULL DEFAULT '0',
  `eximage` varchar(255) DEFAULT NULL,
  `shuxing` char(30) DEFAULT NULL,
  `zishu` mediumint(20) unsigned DEFAULT '0',
  `is_pdf` tinyint(1) unsigned  NOT NULL DEFAULT '0',
  `hascol` int(11) unsigned  NOT NULL DEFAULT '0',
  `yuepiao` int(11) unsigned  NOT NULL DEFAULT '0',
  `tuijianpiao` int(11) unsigned  NOT NULL DEFAULT '0',
  `cuigengpiao` int(11) unsigned  NOT NULL DEFAULT '0',
  `caijiid` varchar(255) DEFAULT NULL,
  `authorinfo` text,
  `sign` int(2) unsigned NOT NULL DEFAULT '0',
  PRIMARY KEY (`book_id`),
  KEY `category_id` (`category_id`),
  KEY `parent_id` (`parent_id`),
  KEY `status` (`status`),
  KEY `viewstime` (`views`,`addtime`),
  KEY `favorestime` (`favores`,`addtime`),
  KEY `istoptime` (`is_top`,`addtime`),
  KEY `scorestime` (`scores`,`addtime`),
  KEY `yuepiaotime` (`yuepiao`,`addtime`),
  KEY `cuigengpiaotime` (`cuigengpiao`,`addtime`),
  KEY `tuijianpiaotime` (`tuijianpiao`,`addtime`),
  KEY `uid` (`uid`)
);
DROP TABLE IF EXISTS `cdb_jamesonread_topics`;
CREATE TABLE `cdb_jamesonread_topics` (
  `topic_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) NOT NULL,
  `descro` varchar(255) NOT NULL,
  `book_1` int(11) unsigned NOT NULL,
  `book_2` int(11) unsigned NOT NULL,
  `book_3` int(11) unsigned NOT NULL,
  `book_4` int(11) unsigned NOT NULL,
  `book_5` int(11) unsigned NOT NULL,
  `book_6` int(11) unsigned NOT NULL,
  `enable` tinyint(2) unsigned NOT NULL DEFAULT '1',
  `addtime` int(11) unsigned NOT NULL,
  `ordernum` int(2) unsigned NOT NULL DEFAULT '1',
  `type` int(5) unsigned NOT NULL DEFAULT '0',
  `image` text,
  `url` varchar(255) DEFAULT NULL,
  `adv` text,
  PRIMARY KEY (`topic_id`),
  KEY `type` (`type`)
);
DROP TABLE IF EXISTS `cdb_jamesonread_categorys`;
CREATE TABLE `cdb_jamesonread_categorys` (
  `category_id` int(11)  unsigned NOT NULL AUTO_INCREMENT,
  `parent_id` int(11) unsigned  NOT NULL,
  `category_name` char(80) NOT NULL,
  `desco` char(255) DEFAULT NULL,
  `is_top` tinyint(1) unsigned  NOT NULL DEFAULT '0',
  `is_display` tinyint(1) unsigned  NOT NULL,
  `addtime` int(11) unsigned  NOT NULL,
  `ordernum` int(6) unsigned  NOT NULL DEFAULT '1',
  PRIMARY KEY (`category_id`),
  KEY `parent_id` (`parent_id`)
);
DROP TABLE IF EXISTS `cdb_jamesonread_update`;
CREATE TABLE `cdb_jamesonread_update` (
  `book_id` int(11) unsigned  NOT NULL,
  `tid` int(11) unsigned  NOT NULL,
  `pid` int(11) unsigned  NOT NULL,
  `category_id` int(11) unsigned  NOT NULL,
  `parent_id` int(11) unsigned  NOT NULL,
  `addtime` int(11) unsigned  NOT NULL,
  `book_name` char(255) NOT NULL,
  `image` char(255) NOT NULL,
  `subject` char(255) NOT NULL,
  `author` char(255) NOT NULL,
  KEY `category_id` (`category_id`),
  KEY `parent_id` (`parent_id`),
  PRIMARY KEY `book_id` (`book_id`)
);
INSERT INTO `cdb_common_setting` (`skey`,`svalue`) VALUES ('xf512read_mbstyle','display: block;margin: 8px auto;padding: 10px;text-align: center;clear: both;background: #F44336;font-size: 14px;color: #fff;')
EOF;
runquery($sql);
require './source/plugin/jameson_read/' . currentlang() . '.php';

$finish = true;